﻿
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SZHL.Data;

namespace SZHL.UI.AppCode
{

    public partial class DownLoadFile : Page
    {

        public string type
        {
            get { return Request.QueryString["type"] ?? "file"; }
        }

        public string MD5
        {
            get { return Request.QueryString["MD5"] ?? ""; }
        }
        public string Name
        {
            get { return Request.QueryString["Name"] ?? "测试文件"; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (type=="file")
            {
                JH_Auth_QY QYinfo = new JH_Auth_QYB().GetEntities().FirstOrDefault();

                Response.AddHeader("Content-Disposition", "attachment;filename=" + Name);
                Response.ContentType = "application/octet-stream";


                string filename = QYinfo.FileServerUrl + MD5;
                Response.Redirect(filename);
            }
            if (type == "folder")
            {
                JH_Auth_QY QYinfo = new JH_Auth_QYB().GetEntities().FirstOrDefault();

                Response.AddHeader("Content-Disposition", "attachment;filename=" + Name);
                Response.ContentType = "application/octet-stream";

                string filename = QYinfo.FileServerUrl + "zipfile/" + MD5;
                Response.Redirect(filename);

            }
        
            // Response.ContentType = "application/x-zip-compressed";
        }
    }
}